summaryrefslogtreecommitdiff
path: root/pages/api/notes/[[...slug]].ts
blob: b0df82a65380d49ce202d728bb92a3ab20071a8a (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import fs from 'fs'

export default async function handler(req: any, res: any) {
  const { slug } = req.query
  const stuff = slug.join('')
  console.log(stuff)
  const uri = decodeURIComponent(slug)
  const prefix = uri.includes('\\') ? '' : '/'
  const path = `${uri}`
  try {
    const text = fs.readFileSync(`${path}`, { encoding: 'utf-8' })
    res.end(`${text}`)
  } catch (e) {
    res.end(`Oopsie Whoopsie! We did a fucky wucky!`)
    console.log(e)
  }
}